package day015.homework.p9;

import java.util.HashMap;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
//        String str = "helloworld java";
        String str = "abcacbacabcba";

        HashMap<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == ' ') {
                continue;
            }
            if (map.containsKey(str.charAt(i))) {
                map.put(str.charAt(i), map.get(str.charAt(i)) + 1);
            } else {
                map.put(str.charAt(i), 1);
            }
        }

        Set<Character> set = map.keySet();
        for (Character c : set) {
            System.out.print(c + "(" + map.get(c) + ")");
        }
    }
}
